package com.jumi.microservice.service;

import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.domain.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * 库存中心对订单中心提供的接口
 *
 * @author Administrator
 */
public interface IOrderInventoryService {

    /**
     * 通知库存中心，“提交订单”事件 (乐观锁实现方式)
     *
     * @param orderItems 订单DTO集合
     * @return OrderInventoryDTO 处理结果
     * @Exception Exception 异常信息
     */
    ResponseResult<OrderInventoryDTO> informSubmitOrderEvent(List<OrderItemDTO> orderItems) throws Exception;

    /**
     * 通知库存中心，“提交订单”事件(Redis)
     *
     * @param orderItems 订单DTO集合
     * @return OrderInventoryDTO 处理结果
     * @Exception Exception 异常信息
     */
    ResponseResult<OrderInventoryDTO> informSubmitOrderEventV2(List<OrderItemDTO> orderItems) throws Exception;


    /**
     * 通知库存中心，“取消订单”事件
     *
     * @param orderDTO 订单DTO
     * @return 处理结果
     */
    @RequestMapping(value = "/informCancelOrderEvent", method = RequestMethod.PUT)
    Boolean informCancelOrderEvent(@RequestBody OrderItemDTO orderDTO);

    /**
     * 订单-预售转真实
     *
     * @param orderDTO 订单DTO
     * @return
     */
    @RequestMapping(value = "/preSaleOrderEvent", method = RequestMethod.PUT)
    ResponseResult preSaleOrderEvent(@RequestBody OrderWareStockDTO orderDTO);

    /**
     * 通知库存中心，“订单调仓”事件
     *
     * @param transferWarehouses 订单调仓信息DTO集合
     * @return Boolean 处理结果
     */
    Boolean transferWarehouseEvent(List<TransferWarehouseDTO> transferWarehouses);

    /**
     * 订单管理-审核订单校验库存量
     * @param supplyStockDeduct
     * @return true: 库存充足, false: 库存不足
     */
    Boolean deductStockBySkuId(SupplyStockDeductDTO supplyStockDeduct);
}
